---
feature_name: "Service Worker Sample: Custom Offline Page"
chrome_version: 40
feature_id: 6561526227927040
---

<h3>Background</h3>
<p>
  This sample demonstrates basic service worker registration. During the installation step, a
  custom "Sorry, you're offline." page is cached. The service worker handles all fetch requests
  for HTML pages (ignoring other requests), and if fetching an HTML page fails due to a network
  error, it will instead return the cached "offline" page.
</p>

<p>
  Try disconnecting from your network, and then reload this page.
</p>

{% include js_snippet.html filename='index.js' title="This Page's JavaScript" %}
{% include js_snippet.html filename='service-worker.js' displayonly=true title="Service Worker's JavaScript" %}
